package com.sskj.mine.asset;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.asset.data.CoinTypeBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.presenter.BasePresenter;
import com.sskj.mine.asset.TransferActivity;

import java.util.List;


/**
 * @author Hey
 * Create at  2019/05/04
 */
class TransferPresenter extends BasePresenter<TransferActivity> {


    /**
     * 站内转账
     *
     * @param price 数量
     * @param pid   币id
     * @param tpwd  交易密码
     * @param ouid  用户ID
     * @return
     */
    public void transfer(String price, String pid, String tpwd, String ouid) {
        httpService.transfer(price, pid, tpwd, ouid).execute(new JsonCallBack<HttpData>(this) {
            @Override
            public void onSuccess(Response<HttpData> response) {
                HttpData httpData = response.body();
                ToastUtil.showShort(httpData.getMsg());
                if (httpData.getStatus() == HttpConfig.OK) {
mView.transferSuccess();
                }
            }
        });
    }

    public void getAssetType() {
        httpService.getAssetType()
                .execute(new JsonCallBack<HttpData<List<CoinTypeBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<CoinTypeBean>>> response) {
                        HttpData<List<CoinTypeBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {

                            mView.updateAssetType(httpData.getData());
                        }
                    }
                });
    }
}
